<template>
  <div class="phone">
    <van-cell-group inset>
      <!-- 输入手机号，调起手机号键盘 -->
      <van-field
        v-model="tel"
        type="tel"
        label="手机号"
        placeholder="请输入手机号"
      />
    </van-cell-group>
    <van-button
      color="linear-gradient(to right, #ff6034, #ee0a24)"
      @click="updatephone"
    >
      确认修改手机号
    </van-button>
  </div>
</template>

<script>
import request from "@/utils/request";
import { showNotify } from "vant";
export default {
  data() {
    return {
      tel: "",
    };
  },
  created() {
    this.tel = localStorage.getItem("phonenumber");
  },
  methods: {
    // 修改手机号
    async updatephone() {
      const id = localStorage.getItem("id");
      const result = await request.get(
        `/good/updataphone?id=${id}&phone=${this.tel}`
      );
      if (result.data.code === 200) {
        showNotify({ type: "success", message: result.data.message });
      }
    },
  },
};
</script>

<style lang="scss">
.van-button--normal {
  width: 80%;
  margin-left: 10%;
}
</style>
